home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / fileutil.13 / fileutil / fileutils-3.13 / lib / posixtm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-06  |  24.0 KB  |  1,000 lines

  1.  
  2. /*  A Bison parser, made from ./posixtm.y
  3.  by  GNU Bison version 1.25
  4.   */
  5.  
  6. #define YYBISON 1  /* Identify Bison output.  */
  7.  
  8. #define    DIGIT    258
  9.  
  10. #line 19 "./posixtm.y"
  11.  
  12.  
  13. #ifdef HAVE_CONFIG_H
  14. #include <config.h>
  15. #endif
  16.  
  17. /* The following block of alloca-related preprocessor directives is here
  18.    solely to allow compilation by non GNU-C compilers of the C parser
  19.    produced from this file by old versions of bison.  Newer versions of
  20.    bison include a block similar to this one in bison.simple.  */
  21.    
  22. #ifdef __GNUC__
  23. #define alloca __builtin_alloca
  24. #else
  25. #ifdef HAVE_ALLOCA_H
  26. #include <alloca.h>
  27. #else
  28. #ifdef _AIX
  29.  #pragma alloca
  30. #else
  31. void *alloca ();
  32. #endif
  33. #endif
  34. #endif
  35.  
  36. #include <stdio.h>
  37. #include <sys/types.h>
  38.  
  39. #ifdef TM_IN_SYS_TIME
  40. #include <sys/time.h>
  41. #else
  42. #include <time.h>
  43. #endif
  44.  
  45. /* Some old versions of bison generate parsers that use bcopy.
  46.    That loses on systems that don't provide the function, so we have
  47.    to redefine it here.  */
  48. #if !defined (HAVE_BCOPY) && defined (HAVE_MEMCPY) && !defined (bcopy)
  49. #define bcopy(from, to, len) memcpy ((to), (from), (len))
  50. #endif
  51.  
  52. #define YYDEBUG 1
  53.  
  54. /* Lexical analyzer's current scan position in the input string. */
  55. static char *curpos;
  56.  
  57. /* The return value. */
  58. static struct tm t;
  59.  
  60. time_t mktime ();
  61.  
  62. #define zzparse posixtime_zzparse
  63. static int zzlex ();
  64. static int zzerror ();
  65. #ifndef YYSTYPE
  66. #define YYSTYPE int
  67. #endif
  68. #include <stdio.h>
  69.  
  70. #ifndef __cplusplus
  71. #ifndef __STDC__
  72. #define const
  73. #endif
  74. #endif
  75.  
  76.  
  77.  
  78. #define    YYFINAL        15
  79. #define    YYFLAG        -32768
  80. #define    YYNTBASE    5
  81.  
  82. #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? zztranslate[x] : 9)
  83.  
  84. static const char zztranslate[] = {     0,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     4,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  102.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  103.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  104.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  105.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  106.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  107.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  108.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  109.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  110.      2,     2,     2,     2,     2,     1,     2,     3
  111. };
  112.  
  113. #if YYDEBUG != 0
  114. static const short zzprhs[] = {     0,
  115.      0,     7,     9,    12,    13,    14,    17
  116. };
  117.  
  118. static const short zzrhs[] = {     8,
  119.      8,     8,     8,     6,     7,     0,     8,     0,     8,     8,
  120.      0,     0,     0,     4,     8,     0,     3,     3,     0
  121. };
  122.  
  123. #endif
  124.  
  125. #if YYDEBUG != 0
  126. static const short zzrline[] = { 0,
  127.     78,   107,   114,   121,   132,   135,   144
  128. };
  129. #endif
  130.  
  131.  
  132. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  133.  
  134. static const char * const zztname[] = {   "$","error","$undefined.","DIGIT",
  135. "'.'","date","year","seconds","digitpair", NULL
  136. };
  137. #endif
  138.  
  139. static const short zzr1[] = {     0,
  140.      5,     6,     6,     6,     7,     7,     8
  141. };
  142.  
  143. static const short zzr2[] = {     0,
  144.      6,     1,     2,     0,     0,     2,     2
  145. };
  146.  
  147. static const short zzdefact[] = {     0,
  148.      0,     0,     7,     0,     0,     4,     5,     2,     0,     1,
  149.      3,     6,     0,     0,     0
  150. };
  151.  
  152. static const short zzdefgoto[] = {    13,
  153.      7,    10,     2
  154. };
  155.  
  156. static const short zzpact[] = {     2,
  157.      5,     2,-32768,     2,     2,     2,    -3,     2,     2,-32768,
  158. -32768,-32768,     9,    10,-32768
  159. };
  160.  
  161. static const short zzpgoto[] = {-32768,
  162. -32768,-32768,    -2
  163. };
  164.  
  165.  
  166. #define    YYLAST        10
  167.  
  168.  
  169. static const short zztable[] = {     4,
  170.      9,     5,     6,     8,     1,    11,    12,     3,    14,    15
  171. };
  172.  
  173. static const short zzcheck[] = {     2,
  174.      4,     4,     5,     6,     3,     8,     9,     3,     0,     0
  175. };
  176. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  177. #line 3 "/p/share/bison.simple"
  178.  
  179. /* Skeleton output parser for bison,
  180.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  181.  
  182.    This program is free software; you can redistribute it and/or modify
  183.    it under the terms of the GNU General Public License as published by
  184.    the Free Software Foundation; either version 2, or (at your option)
  185.    any later version.
  186.  
  187.    This program is distributed in the hope that it will be useful,
  188.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  189.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  190.    GNU General Public License for more details.
  191.  
  192.    You should have received a copy of the GNU General Public License
  193.    along with this program; if not, write to the Free Software
  194.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  195.  
  196. /* As a special exception, when this file is copied by Bison into a
  197.    Bison output file, you may use that output file without restriction.
  198.    This special exception was added by the Free Software Foundation
  199.    in version 1.24 of Bison.  */
  200.  
  201. #ifndef alloca
  202. #ifdef __GNUC__
  203. #define alloca __builtin_alloca
  204. #else /* not GNU C.  */
  205. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  206. #include <alloca.h>
  207. #else /* not sparc */
  208. #if defined (MSDOS) && !defined (__TURBOC__)
  209. #include <malloc.h>
  210. #else /* not MSDOS, or __TURBOC__ */
  211. #if defined(_AIX)
  212. #include <malloc.h>
  213.  #pragma alloca
  214. #else /* not MSDOS, __TURBOC__, or _AIX */
  215. #ifdef __hpux
  216. #ifdef __cplusplus
  217. extern "C" {
  218. void *alloca (unsigned int);
  219. };
  220. #else /* not __cplusplus */
  221. void *alloca ();
  222. #endif /* not __cplusplus */
  223. #endif /* __hpux */
  224. #endif /* not _AIX */
  225. #endif /* not MSDOS, or __TURBOC__ */
  226. #endif /* not sparc.  */
  227. #endif /* not GNU C.  */
  228. #endif /* alloca not defined.  */
  229.  
  230. /* This is the parser code that is written into each bison parser
  231.   when the %semantic_parser declaration is not specified in the grammar.
  232.   It was written by Richard Stallman by simplifying the hairy parser
  233.   used when %semantic_parser is specified.  */
  234.  
  235. /* Note: there must be only one dollar sign in this file.
  236.    It is replaced by the list of actions, each action
  237.    as one case of the switch.  */
  238.  
  239. #define zzerrok        (zzerrstatus = 0)
  240. #define zzclearin    (zzchar = YYEMPTY)
  241. #define YYEMPTY        -2
  242. #define YYEOF        0
  243. #define YYACCEPT    return(0)
  244. #define YYABORT     return(1)
  245. #define YYERROR        goto zzerrlab1
  246. /* Like YYERROR except do call zzerror.
  247.    This remains here temporarily to ease the
  248.    transition to the new meaning of YYERROR, for GCC.
  249.    Once GCC version 2 has supplanted version 1, this can go.  */
  250. #define YYFAIL        goto zzerrlab
  251. #define YYRECOVERING()  (!!zzerrstatus)
  252. #define YYBACKUP(token, value) \
  253. do                                \
  254.   if (zzchar == YYEMPTY && zzlen == 1)                \
  255.     { zzchar = (token), zzlval = (value);            \
  256.       zzchar1 = YYTRANSLATE (zzchar);                \
  257.       YYPOPSTACK;                        \
  258.       goto zzbackup;                        \
  259.     }                                \
  260.   else                                \
  261.     { zzerror ("syntax error: cannot back up"); YYERROR; }    \
  262. while (0)
  263.  
  264. #define YYTERROR    1
  265. #define YYERRCODE    256
  266.  
  267. #ifndef YYPURE
  268. #define YYLEX        zzlex()
  269. #endif
  270.  
  271. #ifdef YYPURE
  272. #ifdef YYLSP_NEEDED
  273. #ifdef YYLEX_PARAM
  274. #define YYLEX        zzlex(&zzlval, &zzlloc, YYLEX_PARAM)
  275. #else
  276. #define YYLEX        zzlex(&zzlval, &zzlloc)
  277. #endif
  278. #else /* not YYLSP_NEEDED */
  279. #ifdef YYLEX_PARAM
  280. #define YYLEX        zzlex(&zzlval, YYLEX_PARAM)
  281. #else
  282. #define YYLEX        zzlex(&zzlval)
  283. #endif
  284. #endif /* not YYLSP_NEEDED */
  285. #endif
  286.  
  287. /* If nonreentrant, generate the variables here */
  288.  
  289. #ifndef YYPURE
  290.  
  291. int    zzchar;            /*  the lookahead symbol        */
  292. YYSTYPE    zzlval;            /*  the semantic value of the        */
  293.                 /*  lookahead symbol            */
  294.  
  295. #ifdef YYLSP_NEEDED
  296. YYLTYPE zzlloc;            /*  location data for the lookahead    */
  297.                 /*  symbol                */
  298. #endif
  299.  
  300. int zznerrs;            /*  number of parse errors so far       */
  301. #endif  /* not YYPURE */
  302.  
  303. #if YYDEBUG != 0
  304. int zzdebug;            /*  nonzero means print parse trace    */
  305. /* Since this is uninitialized, it does not stop multiple parsers
  306.    from coexisting.  */
  307. #endif
  308.  
  309. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  310.  
  311. #ifndef    YYINITDEPTH
  312. #define YYINITDEPTH 200
  313. #endif
  314.  
  315. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  316.     (effective only if the built-in stack extension method is used).  */
  317.  
  318. #if YYMAXDEPTH == 0
  319. #undef YYMAXDEPTH
  320. #endif
  321.  
  322. #ifndef YYMAXDEPTH
  323. #define YYMAXDEPTH 10000
  324. #endif
  325.  
  326. /* Prevent warning if -Wstrict-prototypes.  */
  327. #ifdef __GNUC__
  328. int zzparse (void);
  329. #endif
  330.  
  331. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  332. #define __zz_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  333. #else                /* not GNU C or C++ */
  334. #ifndef __cplusplus
  335.  
  336. /* This is the most reliable way to avoid incompatibilities
  337.    in available built-in functions on various systems.  */
  338. static void
  339. __zz_memcpy (to, from, count)
  340.      char *to;
  341.      char *from;
  342.      int count;
  343. {
  344.   register char *f = from;
  345.   register char *t = to;
  346.   register int i = count;
  347.  
  348.   while (i-- > 0)
  349.     *t++ = *f++;
  350. }
  351.  
  352. #else /* __cplusplus */
  353.  
  354. /* This is the most reliable way to avoid incompatibilities
  355.    in available built-in functions on various systems.  */
  356. static void
  357. __zz_memcpy (char *to, char *from, int count)
  358. {
  359.   register char *t = to;
  360.   register char *f = from;
  361.   register int i = count;
  362.  
  363.   while (i-- > 0)
  364.     *t++ = *f++;
  365. }
  366.  
  367. #endif
  368. #endif
  369.  
  370. #line 196 "/p/share/bison.simple"
  371.  
  372. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  373.    into zzparse.  The argument should have type void *.
  374.    It should actually point to an object.
  375.    Grammar actions can access the variable by casting it
  376.    to the proper pointer type.  */
  377.  
  378. #ifdef YYPARSE_PARAM
  379. #ifdef __cplusplus
  380. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  381. #define YYPARSE_PARAM_DECL
  382. #else /* not __cplusplus */
  383. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  384. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  385. #endif /* not __cplusplus */
  386. #else /* not YYPARSE_PARAM */
  387. #define YYPARSE_PARAM_ARG
  388. #define YYPARSE_PARAM_DECL
  389. #endif /* not YYPARSE_PARAM */
  390.  
  391. int
  392. zzparse(YYPARSE_PARAM_ARG)
  393.      YYPARSE_PARAM_DECL
  394. {
  395.   register int zzstate;
  396.   register int zzn;
  397.   register short *zzssp;
  398.   register YYSTYPE *zzvsp;
  399.   int zzerrstatus;    /*  number of tokens to shift before error messages enabled */
  400.   int zzchar1 = 0;        /*  lookahead token as an internal (translated) token number */
  401.  
  402.   short    zzssa[YYINITDEPTH];    /*  the state stack            */
  403.   YYSTYPE zzvsa[YYINITDEPTH];    /*  the semantic value stack        */
  404.  
  405.   short *zzss = zzssa;        /*  refer to the stacks thru separate pointers */
  406.   YYSTYPE *zzvs = zzvsa;    /*  to allow zzoverflow to reallocate them elsewhere */
  407.  
  408. #ifdef YYLSP_NEEDED
  409.   YYLTYPE zzlsa[YYINITDEPTH];    /*  the location stack            */
  410.   YYLTYPE *zzls = zzlsa;
  411.   YYLTYPE *zzlsp;
  412.  
  413. #define YYPOPSTACK   (zzvsp--, zzssp--, zzlsp--)
  414. #else
  415. #define YYPOPSTACK   (zzvsp--, zzssp--)
  416. #endif
  417.  
  418.   int zzstacksize = YYINITDEPTH;
  419.  
  420. #ifdef YYPURE
  421.   int zzchar;
  422.   YYSTYPE zzlval;
  423.   int zznerrs;
  424. #ifdef YYLSP_NEEDED
  425.   YYLTYPE zzlloc;
  426. #endif
  427. #endif
  428.  
  429.   YYSTYPE zzval;        /*  the variable used to return        */
  430.                 /*  semantic values from the action    */
  431.                 /*  routines                */
  432.  
  433.   int zzlen;
  434.  
  435. #if YYDEBUG != 0
  436.   if (zzdebug)
  437.     fprintf(stderr, "Starting parse\n");
  438. #endif
  439.  
  440.   zzstate = 0;
  441.   zzerrstatus = 0;
  442.   zznerrs = 0;
  443.   zzchar = YYEMPTY;        /* Cause a token to be read.  */
  444.  
  445.   /* Initialize stack pointers.
  446.      Waste one element of value and location stack
  447.      so that they stay on the same level as the state stack.
  448.      The wasted elements are never initialized.  */
  449.  
  450.   zzssp = zzss - 1;
  451.   zzvsp = zzvs;
  452. #ifdef YYLSP_NEEDED
  453.   zzlsp = zzls;
  454. #endif
  455.  
  456. /* Push a new state, which is found in  zzstate  .  */
  457. /* In all cases, when you get here, the value and location stacks
  458.    have just been pushed. so pushing a state here evens the stacks.  */
  459. zznewstate:
  460.  
  461.   *++zzssp = zzstate;
  462.  
  463.   if (zzssp >= zzss + zzstacksize - 1)
  464.     {
  465.       /* Give user a chance to reallocate the stack */
  466.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  467.       YYSTYPE *zzvs1 = zzvs;
  468.       short *zzss1 = zzss;
  469. #ifdef YYLSP_NEEDED
  470.       YYLTYPE *zzls1 = zzls;
  471. #endif
  472.  
  473.       /* Get the current used size of the three stacks, in elements.  */
  474.       int size = zzssp - zzss + 1;
  475.  
  476. #ifdef zzoverflow
  477.       /* Each stack pointer address is followed by the size of
  478.      the data in use in that stack, in bytes.  */
  479. #ifdef YYLSP_NEEDED
  480.       /* This used to be a conditional around just the two extra args,
  481.      but that might be undefined if zzoverflow is a macro.  */
  482.       zzoverflow("parser stack overflow",
  483.          &zzss1, size * sizeof (*zzssp),
  484.          &zzvs1, size * sizeof (*zzvsp),
  485.          &zzls1, size * sizeof (*zzlsp),
  486.          &zzstacksize);
  487. #else
  488.       zzoverflow("parser stack overflow",
  489.          &zzss1, size * sizeof (*zzssp),
  490.          &zzvs1, size * sizeof (*zzvsp),
  491.          &zzstacksize);
  492. #endif
  493.  
  494.       zzss = zzss1; zzvs = zzvs1;
  495. #ifdef YYLSP_NEEDED
  496.       zzls = zzls1;
  497. #endif
  498. #else /* no zzoverflow */
  499.       /* Extend the stack our own way.  */
  500.       if (zzstacksize >= YYMAXDEPTH)
  501.     {
  502.       zzerror("parser stack overflow");
  503.       return 2;
  504.     }
  505.       zzstacksize *= 2;
  506.       if (zzstacksize > YYMAXDEPTH)
  507.     zzstacksize = YYMAXDEPTH;
  508.       zzss = (short *) alloca (zzstacksize * sizeof (*zzssp));
  509.       __zz_memcpy ((char *)zzss, (char *)zzss1, size * sizeof (*zzssp));
  510.       zzvs = (YYSTYPE *) alloca (zzstacksize * sizeof (*zzvsp));
  511.       __zz_memcpy ((char *)zzvs, (char *)zzvs1, size * sizeof (*zzvsp));
  512. #ifdef YYLSP_NEEDED
  513.       zzls = (YYLTYPE *) alloca (zzstacksize * sizeof (*zzlsp));
  514.       __zz_memcpy ((char *)zzls, (char *)zzls1, size * sizeof (*zzlsp));
  515. #endif
  516. #endif /* no zzoverflow */
  517.  
  518.       zzssp = zzss + size - 1;
  519.       zzvsp = zzvs + size - 1;
  520. #ifdef YYLSP_NEEDED
  521.       zzlsp = zzls + size - 1;
  522. #endif
  523.  
  524. #if YYDEBUG != 0
  525.       if (zzdebug)
  526.     fprintf(stderr, "Stack size increased to %d\n", zzstacksize);
  527. #endif
  528.  
  529.       if (zzssp >= zzss + zzstacksize - 1)
  530.     YYABORT;
  531.     }
  532.  
  533. #if YYDEBUG != 0
  534.   if (zzdebug)
  535.     fprintf(stderr, "Entering state %d\n", zzstate);
  536. #endif
  537.  
  538.   goto zzbackup;
  539.  zzbackup:
  540.  
  541. /* Do appropriate processing given the current state.  */
  542. /* Read a lookahead token if we need one and don't already have one.  */
  543. /* zzresume: */
  544.  
  545.   /* First try to decide what to do without reference to lookahead token.  */
  546.  
  547.   zzn = zzpact[zzstate];
  548.   if (zzn == YYFLAG)
  549.     goto zzdefault;
  550.  
  551.   /* Not known => get a lookahead token if don't already have one.  */
  552.  
  553.   /* zzchar is either YYEMPTY or YYEOF
  554.      or a valid token in external form.  */
  555.  
  556.   if (zzchar == YYEMPTY)
  557.     {
  558. #if YYDEBUG != 0
  559.       if (zzdebug)
  560.     fprintf(stderr, "Reading a token: ");
  561. #endif
  562.       zzchar = YYLEX;
  563.     }
  564.  
  565.   /* Convert token to internal form (in zzchar1) for indexing tables with */
  566.  
  567.   if (zzchar <= 0)        /* This means end of input. */
  568.     {
  569.       zzchar1 = 0;
  570.       zzchar = YYEOF;        /* Don't call YYLEX any more */
  571.  
  572. #if YYDEBUG != 0
  573.       if (zzdebug)
  574.     fprintf(stderr, "Now at end of input.\n");
  575. #endif
  576.     }
  577.   else
  578.     {
  579.       zzchar1 = YYTRANSLATE(zzchar);
  580.  
  581. #if YYDEBUG != 0
  582.       if (zzdebug)
  583.     {
  584.       fprintf (stderr, "Next token is %d (%s", zzchar, zztname[zzchar1]);
  585.       /* Give the individual parser a way to print the precise meaning
  586.          of a token, for further debugging info.  */
  587. #ifdef YYPRINT
  588.       YYPRINT (stderr, zzchar, zzlval);
  589. #endif
  590.       fprintf (stderr, ")\n");
  591.     }
  592. #endif
  593.     }
  594.  
  595.   zzn += zzchar1;
  596.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != zzchar1)
  597.     goto zzdefault;
  598.  
  599.   zzn = zztable[zzn];
  600.  
  601.   /* zzn is what to do for this token type in this state.
  602.      Negative => reduce, -zzn is rule number.
  603.      Positive => shift, zzn is new state.
  604.        New state is final state => don't bother to shift,
  605.        just return success.
  606.      0, or most negative number => error.  */
  607.  
  608.   if (zzn < 0)
  609.     {
  610.       if (zzn == YYFLAG)
  611.     goto zzerrlab;
  612.       zzn = -zzn;
  613.       goto zzreduce;
  614.     }
  615.   else if (zzn == 0)
  616.     goto zzerrlab;
  617.  
  618.   if (zzn == YYFINAL)
  619.     YYACCEPT;
  620.  
  621.   /* Shift the lookahead token.  */
  622.  
  623. #if YYDEBUG != 0
  624.   if (zzdebug)
  625.     fprintf(stderr, "Shifting token %d (%s), ", zzchar, zztname[zzchar1]);
  626. #endif
  627.  
  628.   /* Discard the token being shifted unless it is eof.  */
  629.   if (zzchar != YYEOF)
  630.     zzchar = YYEMPTY;
  631.  
  632.   *++zzvsp = zzlval;
  633. #ifdef YYLSP_NEEDED
  634.   *++zzlsp = zzlloc;
  635. #endif
  636.  
  637.   /* count tokens shifted since error; after three, turn off error status.  */
  638.   if (zzerrstatus) zzerrstatus--;
  639.  
  640.   zzstate = zzn;
  641.   goto zznewstate;
  642.  
  643. /* Do the default action for the current state.  */
  644. zzdefault:
  645.  
  646.   zzn = zzdefact[zzstate];
  647.   if (zzn == 0)
  648.     goto zzerrlab;
  649.  
  650. /* Do a reduction.  zzn is the number of a rule to reduce with.  */
  651. zzreduce:
  652.   zzlen = zzr2[zzn];
  653.   if (zzlen > 0)
  654.     zzval = zzvsp[1-zzlen]; /* implement default value of the action */
  655.  
  656. #if YYDEBUG != 0
  657.   if (zzdebug)
  658.     {
  659.       int i;
  660.  
  661.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  662.            zzn, zzrline[zzn]);
  663.  
  664.       /* Print the symbols being reduced, and their result.  */
  665.       for (i = zzprhs[zzn]; zzrhs[i] > 0; i++)
  666.     fprintf (stderr, "%s ", zztname[zzrhs[i]]);
  667.       fprintf (stderr, " -> %s\n", zztname[zzr1[zzn]]);
  668.     }
  669. #endif
  670.  
  671.  
  672.   switch (zzn) {
  673.  
  674. case 1:
  675. #line 84 "./posixtm.y"
  676. {
  677.              if (zzvsp[-5] >= 1 && zzvsp[-5] <= 12)
  678.            t.tm_mon = zzvsp[-5] - 1;
  679.          else {
  680.            YYABORT;
  681.          }
  682.          if (zzvsp[-4] >= 1 && zzvsp[-4] <= 31)
  683.            t.tm_mday = zzvsp[-4];
  684.          else {
  685.            YYABORT;
  686.          }
  687.          if (zzvsp[-3] >= 0 && zzvsp[-3] <= 23)
  688.            t.tm_hour = zzvsp[-3];
  689.          else {
  690.            YYABORT;
  691.          }
  692.          if (zzvsp[-2] >= 0 && zzvsp[-2] <= 59)
  693.            t.tm_min = zzvsp[-2];
  694.          else {
  695.            YYABORT;
  696.          }
  697.            ;
  698.     break;}
  699. case 2:
  700. #line 107 "./posixtm.y"
  701. {
  702.                    t.tm_year = zzvsp[0];
  703.            /* Deduce the century based on the year.
  704.               See POSIX.2 section 4.63.3.  */
  705.            if (zzvsp[0] <= 68)
  706.              t.tm_year += 100;
  707.          ;
  708.     break;}
  709. case 3:
  710. #line 114 "./posixtm.y"
  711. {
  712.                             t.tm_year = zzvsp[-1] * 100 + zzvsp[0];
  713.                 if (t.tm_year < 1900) {
  714.                   YYABORT;
  715.                 } else
  716.                   t.tm_year -= 1900;
  717.               ;
  718.     break;}
  719. case 4:
  720. #line 121 "./posixtm.y"
  721. {
  722.                     time_t now;
  723.             struct tm *tmp;
  724.  
  725.                     /* Use current year.  */
  726.                     time (&now);
  727.             tmp = localtime (&now);
  728.             t.tm_year = tmp->tm_year;
  729.           ;
  730.     break;}
  731. case 5:
  732. #line 132 "./posixtm.y"
  733. {
  734.                         t.tm_sec = 0;
  735.               ;
  736.     break;}
  737. case 6:
  738. #line 135 "./posixtm.y"
  739. {
  740.                       if (zzvsp[0] >= 0 && zzvsp[0] <= 61)
  741.                 t.tm_sec = zzvsp[0];
  742.               else {
  743.                 YYABORT;
  744.               }
  745.             ;
  746.     break;}
  747. case 7:
  748. #line 144 "./posixtm.y"
  749. {
  750.                           zzval = zzvsp[-1] * 10 + zzvsp[0];
  751.             ;
  752.     break;}
  753. }
  754.    /* the action file gets copied in in place of this dollarsign */
  755. #line 498 "/p/share/bison.simple"
  756.  
  757.   zzvsp -= zzlen;
  758.   zzssp -= zzlen;
  759. #ifdef YYLSP_NEEDED
  760.   zzlsp -= zzlen;
  761. #endif
  762.  
  763. #if YYDEBUG != 0
  764.   if (zzdebug)
  765.     {
  766.       short *ssp1 = zzss - 1;
  767.       fprintf (stderr, "state stack now");
  768.       while (ssp1 != zzssp)
  769.     fprintf (stderr, " %d", *++ssp1);
  770.       fprintf (stderr, "\n");
  771.     }
  772. #endif
  773.  
  774.   *++zzvsp = zzval;
  775.  
  776. #ifdef YYLSP_NEEDED
  777.   zzlsp++;
  778.   if (zzlen == 0)
  779.     {
  780.       zzlsp->first_line = zzlloc.first_line;
  781.       zzlsp->first_column = zzlloc.first_column;
  782.       zzlsp->last_line = (zzlsp-1)->last_line;
  783.       zzlsp->last_column = (zzlsp-1)->last_column;
  784.       zzlsp->text = 0;
  785.     }
  786.   else
  787.     {
  788.       zzlsp->last_line = (zzlsp+zzlen-1)->last_line;
  789.       zzlsp->last_column = (zzlsp+zzlen-1)->last_column;
  790.     }
  791. #endif
  792.  
  793.   /* Now "shift" the result of the reduction.
  794.      Determine what state that goes to,
  795.      based on the state we popped back to
  796.      and the rule number reduced by.  */
  797.  
  798.   zzn = zzr1[zzn];
  799.  
  800.   zzstate = zzpgoto[zzn - YYNTBASE] + *zzssp;
  801.   if (zzstate >= 0 && zzstate <= YYLAST && zzcheck[zzstate] == *zzssp)
  802.     zzstate = zztable[zzstate];
  803.   else
  804.     zzstate = zzdefgoto[zzn - YYNTBASE];
  805.  
  806.   goto zznewstate;
  807.  
  808. zzerrlab:   /* here on detecting error */
  809.  
  810.   if (! zzerrstatus)
  811.     /* If not already recovering from an error, report this error.  */
  812.     {
  813.       ++zznerrs;
  814.  
  815. #ifdef YYERROR_VERBOSE
  816.       zzn = zzpact[zzstate];
  817.  
  818.       if (zzn > YYFLAG && zzn < YYLAST)
  819.     {
  820.       int size = 0;
  821.       char *msg;
  822.       int x, count;
  823.  
  824.       count = 0;
  825.       /* Start X at -zzn if nec to avoid negative indexes in zzcheck.  */
  826.       for (x = (zzn < 0 ? -zzn : 0);
  827.            x < (sizeof(zztname) / sizeof(char *)); x++)
  828.         if (zzcheck[x + zzn] == x)
  829.           size += strlen(zztname[x]) + 15, count++;
  830.       msg = (char *) malloc(size + 15);
  831.       if (msg != 0)
  832.         {
  833.           strcpy(msg, "parse error");
  834.  
  835.           if (count < 5)
  836.         {
  837.           count = 0;
  838.           for (x = (zzn < 0 ? -zzn : 0);
  839.                x < (sizeof(zztname) / sizeof(char *)); x++)
  840.             if (zzcheck[x + zzn] == x)
  841.               {
  842.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  843.             strcat(msg, zztname[x]);
  844.             strcat(msg, "'");
  845.             count++;
  846.               }
  847.         }
  848.           zzerror(msg);
  849.           free(msg);
  850.         }
  851.       else
  852.         zzerror ("parse error; also virtual memory exceeded");
  853.     }
  854.       else
  855. #endif /* YYERROR_VERBOSE */
  856.     zzerror("parse error");
  857.     }
  858.  
  859.   goto zzerrlab1;
  860. zzerrlab1:   /* here on error raised explicitly by an action */
  861.  
  862.   if (zzerrstatus == 3)
  863.     {
  864.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  865.  
  866.       /* return failure if at end of input */
  867.       if (zzchar == YYEOF)
  868.     YYABORT;
  869.  
  870. #if YYDEBUG != 0
  871.       if (zzdebug)
  872.     fprintf(stderr, "Discarding token %d (%s).\n", zzchar, zztname[zzchar1]);
  873. #endif
  874.  
  875.       zzchar = YYEMPTY;
  876.     }
  877.  
  878.   /* Else will try to reuse lookahead token
  879.      after shifting the error token.  */
  880.  
  881.   zzerrstatus = 3;        /* Each real token shifted decrements this */
  882.  
  883.   goto zzerrhandle;
  884.  
  885. zzerrdefault:  /* current state does not do anything special for the error token. */
  886.  
  887. #if 0
  888.   /* This is wrong; only states that explicitly want error tokens
  889.      should shift them.  */
  890.   zzn = zzdefact[zzstate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  891.   if (zzn) goto zzdefault;
  892. #endif
  893.  
  894. zzerrpop:   /* pop the current state because it cannot handle the error token */
  895.  
  896.   if (zzssp == zzss) YYABORT;
  897.   zzvsp--;
  898.   zzstate = *--zzssp;
  899. #ifdef YYLSP_NEEDED
  900.   zzlsp--;
  901. #endif
  902.  
  903. #if YYDEBUG != 0
  904.   if (zzdebug)
  905.     {
  906.       short *ssp1 = zzss - 1;
  907.       fprintf (stderr, "Error: state stack now");
  908.       while (ssp1 != zzssp)
  909.     fprintf (stderr, " %d", *++ssp1);
  910.       fprintf (stderr, "\n");
  911.     }
  912. #endif
  913.  
  914. zzerrhandle:
  915.  
  916.   zzn = zzpact[zzstate];
  917.   if (zzn == YYFLAG)
  918.     goto zzerrdefault;
  919.  
  920.   zzn += YYTERROR;
  921.   if (zzn < 0 || zzn > YYLAST || zzcheck[zzn] != YYTERROR)
  922.     goto zzerrdefault;
  923.  
  924.   zzn = zztable[zzn];
  925.   if (zzn < 0)
  926.     {
  927.       if (zzn == YYFLAG)
  928.     goto zzerrpop;
  929.       zzn = -zzn;
  930.       goto zzreduce;
  931.     }
  932.   else if (zzn == 0)
  933.     goto zzerrpop;
  934.  
  935.   if (zzn == YYFINAL)
  936.     YYACCEPT;
  937.  
  938. #if YYDEBUG != 0
  939.   if (zzdebug)
  940.     fprintf(stderr, "Shifting error token, ");
  941. #endif
  942.  
  943.   *++zzvsp = zzlval;
  944. #ifdef YYLSP_NEEDED
  945.   *++zzlsp = zzlloc;
  946. #endif
  947.  
  948.   zzstate = zzn;
  949.   goto zznewstate;
  950. }
  951. #line 148 "./posixtm.y"
  952.  
  953. static int
  954. zzlex ()
  955. {
  956.   char ch = *curpos++;
  957.  
  958.   if (ch >= '0' && ch <= '9')
  959.     {
  960.       zzlval = ch - '0';
  961.       return DIGIT;
  962.     }
  963.   else if (ch == '.' || ch == 0)
  964.     return ch;
  965.   else
  966.     return '?';            /* Cause an error.  */
  967. }
  968.  
  969. static int
  970. zzerror ()
  971. {
  972.   return 0;
  973. }
  974.  
  975. /* Parse a POSIX-style date and return it, or (time_t)-1 for an error.  */
  976.  
  977. time_t
  978. posixtime (s)
  979.      char *s;
  980. {
  981.   curpos = s;
  982.   /* Let mktime decide whether it is daylight savings time.  */
  983.   t.tm_isdst = -1;
  984.   if (zzparse ())
  985.     return (time_t)-1;
  986.   else
  987.     return mktime (&t);
  988. }
  989.  
  990. /* Parse a POSIX-style date and return it, or NULL for an error.  */
  991.  
  992. struct tm *
  993. posixtm (s)
  994.      char *s;
  995. {
  996.   if (posixtime (s) == -1)
  997.     return NULL;
  998.   return &t;
  999. }
  1000.